package cn.stylefeng.guns.modular.api.controller;

import cn.stylefeng.guns.base.pojo.page.LayuiPageInfo;
import cn.stylefeng.guns.modular.ums.entity.ShieldCompany;
import cn.stylefeng.guns.modular.ums.model.params.ShieldCompanyParam;
import cn.stylefeng.guns.modular.ums.service.ShieldCompanyService;
import cn.stylefeng.guns.modular.wms.model.params.ApplyLogParam;
import cn.stylefeng.guns.modular.wms.model.params.ApplyReadParam;
import cn.stylefeng.guns.modular.wms.model.result.ApplyLogResult;
import cn.stylefeng.guns.modular.wms.service.ApplyLogService;
import cn.stylefeng.guns.modular.wms.service.ApplyReadService;
import cn.stylefeng.guns.utils.MemberTokenUtil;
import cn.stylefeng.roses.core.base.controller.BaseController;
import cn.stylefeng.roses.core.reqres.response.ResponseData;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 *屏蔽信息管理
 */
@Controller
@RequestMapping("/api/shield")
@Api(tags = "屏蔽信息管理")
public class ApiShiledController extends BaseController {

    @Autowired
    private ShieldCompanyService shieldCompanyService;

    /**
     * 查询屏蔽列表
     */
    @ResponseBody
    @RequestMapping(value = "/getShieldList",method = RequestMethod.GET)
    @ApiOperation(value = "查询屏蔽列表", notes = "查询投递列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "page", value = "页码", dataType = "Integer", paramType = "query"),
            @ApiImplicitParam(name = "limit", value = "每页数量", dataType = "Integer", paramType = "query")
    })
    public ResponseData getApplyList(ShieldCompanyParam param) {
        int memberId=MemberTokenUtil.getMemberId();
        param.setMemberId(memberId);
        LayuiPageInfo pageInfo= shieldCompanyService.findPageBySpec(param);
        return ResponseData.success(pageInfo);
    }


    /**
     * 添加/更新屏蔽
     */
    @ResponseBody
    @RequestMapping(value = "/addOrUpdateShield",method = RequestMethod.POST)
    @ApiOperation(value = "添加/更新屏蔽", notes = "添加/更新屏蔽")
    public ResponseData addOrUpdateApply(@RequestBody ShieldCompanyParam param) {
        try {
            int memberId=MemberTokenUtil.getMemberId();
            param.setMemberId(memberId);
            shieldCompanyService.add(param);
            return ResponseData.success();
        }catch (Exception e){
            return ResponseData.error(e.getMessage());
        }
    }

    /**
     * 删除屏蔽
     */
    @ResponseBody
    @RequestMapping(value = "/deleteShield",method = RequestMethod.POST)
    @ApiOperation(value = "删除屏蔽", notes = "删除屏蔽")
    public ResponseData deleteApply(@RequestBody ShieldCompanyParam param) {
        try {
            shieldCompanyService.removeById(param.getId());
            return ResponseData.success();
        }catch (Exception e){
            return ResponseData.error(e.getMessage());
        }
    }

}



